import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:flutter_screenutil/screenutil.dart';
import 'package:jspang/provide/details_info.dart';
import 'package:provider/provider.dart';

class DetailsWeb extends StatelessWidget {
  const DetailsWeb({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    var goodsDetails = Provider.of<DetailsInfoProvide>(context)
        .goodsInfo
        .data
        .goodInfo
        .goodsDetail;

    return Selector<DetailsInfoProvide, DetailsInfoProvide>(
      selector: (context, provider) => provider,
      shouldRebuild: (pre, next) => true,
      builder: (context, value, child) {
        var isLeft = Provider.of<DetailsInfoProvide>(context,listen: false).isLeft;
        if (isLeft) {
          return Container(
            padding: EdgeInsets.only(bottom: ScreenUtil().setHeight(80)),
            child: Html(
              data: goodsDetails,
            ),
          );
        } else {
          return Container(
            width: ScreenUtil().setWidth(750),
            padding: EdgeInsets.only(bottom: ScreenUtil().setHeight(80)),
            child: Text('暂时没有数据'),
            alignment: Alignment.center,
          );
        }
      },
    );
  }
}
